<div class="row">
	<form class="filter-form" action="${request.contextPath}/contract-manage" method="post">
		<div class="col-md-4">
			<div class="form-group">
				<div class="input-group">
					<div class="input-group-addon">
						<div style="width: 80px;">
							<span class="not-null-star">*</span> 合同日期
						</div>
					</div>
					<input style="background-color: #fff;" type="text" name="dataStart" class="form-control input-sm datetimepicker not-empty" data-format="yyyy-MM-dd" value="${(dataStart?string('yyyy-MM-dd'))!''}" data-foot="false" readonly="readonly" />
					<div class="input-group-addon" style="border-width: 1px 0;">至</div>
					<input style="background-color: #fff;" type="text" name="dataEnd" class="form-control input-sm datetimepicker not-empty" data-format="yyyy-MM-dd" value="${(dataEnd?string('yyyy-MM-dd'))!''}" data-foot="false" readonly="readonly" />
				</div>
			</div>
		</div>
		<div class="col-md-8" style="padding-left: 0;">
			<div class="btn btn-success btn-sm filter-search">查询</div>
			<div class="btn btn-danger btn-sm export-of-year">
				<i class="icon-signout"></i>
				导出结果
			</div>
		</div>
	</form>
</div>

<div class="contract-manage-container">
	<table class="contract-manage" style="min-width: 3000px;">
		<tr class="title-row">
			<th class="text-center" rowspan="2" width="45">序号</th>
			<th class="text-center" rowspan="2">项目编码</th>
			<th class="text-center" rowspan="2">合同名称</th>
			<th class="text-center" rowspan="2" width="100">合同工期</th>
			<th class="text-center" rowspan="2" width="100">实际工期</th>
			<th class="text-center" rowspan="2">建设单位</th>
			<th class="text-center" rowspan="2" width="73">进度情况</th>
			<th class="text-center" rowspan="2">合同金额（元）</th>
			<th class="text-center" colspan="2">结算价</th>
			<th class="text-center" rowspan="2">结算状态</th>
			<th class="text-center" colspan="3">任务书</th>
			<th class="text-center" colspan="3">分包</th>
			<th class="text-center" colspan="3">材料费</th>
			<th class="text-center" rowspan="2">其他费用（元）</th>
			<th class="text-center" rowspan="2">毛利（元）</th>
			<th class="text-center" rowspan="2" width="125">毛利占结算金额的百分比</th>
			<th class="text-center" rowspan="2">竣工资料移交情况</th>
			<th class="text-center" rowspan="2">结算资料移交情况</th>
			<th class="text-center" rowspan="2" width="70">项目负责人</th>
			<th class="text-center" rowspan="2">实施单位</th>
			<th class="text-center" rowspan="2">备注</th>
		</tr>
		<tr>
			<th>金额（元）</th>
			<th>开票情况</th>
			<th>任务金额（元）</th>
			<th>结算金额（元）</th>
			<th>报帐情况</th>
			<th>合同金额（元）</th>
			<th>结算金额（元）</th>
			<th>挂帐情况</th>
			<th>合同金额（元）</th>
			<th>结算金额（元）</th>
			<th>挂帐情况</th>
		</tr>
		<#if data??> <#list data as d>
		<tr>
			<td class="text-center">${d_index+1}</td>
			<td class="text-center">${d.no}</td>
			<td class="text-center">${d.name}</td>
			<td class="text-center">${d.htGq}</td>
			<td class="text-center">${d.sjGq}</td>
			<td class="text-center">${d.companyA}</td>
			<td class="text-center">${d.process}</td>
			<td class="text-center">${(d.priceString)!'-'}</td>
			<td class="text-center">${(d.jsPrice?string('#,##0.00'))!'-'}</td>
			<td class="text-center">${d.jsFapiao}</td>
			<td class="text-center">${d.jsStatus}</td>
			<td class="text-center">${(d.taskPrice?string('#,##0.00'))!'-'}</td>
			<td class="text-center">${(d.taskJsPrice?string('#,##0.00'))!'-'}</td>
			<td class="text-center">${d.taskCompletedStatus}</td>
			<td class="text-center">${(d.subPrice?string('#,##0.00'))!'-'}</td>
			<td class="text-center">${(d.subJsPrice?string('#,##0.00'))!'-'}</td>
			<td class="text-center">${d.subCompletedStatus}</td>
			<td class="text-center">${(d.materialPrice?string('#,##0.00'))!'-'}</td>
			<td class="text-center">${(d.materialJsPrice?string('#,##0.00'))!'-'}</td>
			<td class="text-center">${d.materialCompletedStatus}</td>
			<td class="text-center">${(d.otherPrice?string('#,##0.00'))!'-'}</td>
			<td class="text-center">${(d.lr?string('#,##0.00'))!'-'}</td>
			<td class="text-center">${(d.lrRatio?string('#,##0.00%'))!'-'}</td>
			<td class="text-center">${d.jgFiles}</td>
			<td class="text-center">${d.jsFiles}</td>
			<td class="text-center">${d.header}</td>
			<td class="text-center">${d.companyB}</td>
			<td class="text-center">${d.remark}</td>
		</tr>
		</#list> <#else>
		<tr>
			<td colspan="28">暂无数据</td>
		</tr>
		</#if>
	</table>
</div>

<script type="text/javascript">
	require([ 'suredyList', '${request.contextPath}/app/js/form-checker.js', 'suredyDatetimepicker', 'jqueryForm' ], function(List, formChecker) {
		var doSearch = function(page, pageSize) {
			var form = $('form.filter-form');

			if (!formChecker(form)) {
				return false;
			}

			form.ajaxSubmit({
				dataType : 'html',
				data : {
					page : page,
					pageSize : pageSize
				},
				success : function(html, textStatus, jqXHR) {
					if (!html)
						return false;

					$('div.suredy-content').html(html);
				},
				error : function(jqXHR, textStatus, errorThrown) {
					return false;
				}
			});
		};

		List('table.contract-manage', {
			header : false,
			footer : false,
		});

		$('form.filter-form .btn.filter-search').on('click', function() {
			doSearch(1, $('table.table-bid-list').data('page-size'));
		});

		$('form.filter-form .btn.filter-reset').on('click', function() {
			$('form.filter-form input').val('');
			$('form.filter-form option:first-child').prop('selected', true);
		});

		$('select.select-year').on('change', function() {
			var $this = $(this);

			Suredy.loadContent('${request.contextPath}/contract-manage?year=' + $this.val());
		});

		$('div.btn.export-of-year').on('click', function() {
			var form = $('form.filter-form');

			if (!formChecker(form)) {
				return false;
			}

			var start = $('form.filter-form [name=dataStart]').val();
			var end = $('form.filter-form [name=dataEnd]').val();

			window.open('${request.contextPath}/contract-manage/export?dataStart=' + start + '&dataEnd=' + end, '_blank');
		});
	});
</script>